% 
clc;
clearvars;
SubjectNums=1000;
RunNum=4;
MethodesNum=9;
TotalSubjectNums=SubjectNums*RunNum;
MLEFittedW     = zeros(TotalSubjectNums,MethodesNum,MethodesNum);
MAPFittedW     = zeros(TotalSubjectNums,MethodesNum,MethodesNum);
MLEFittedNLL   = zeros(TotalSubjectNums,MethodesNum,MethodesNum);
MAPFittedNLL   = zeros(TotalSubjectNums,MethodesNum,MethodesNum);
AgentW         = zeros(TotalSubjectNums,MethodesNum);

for Subj=1:300;
for R=1:1
    for P=9
        DataFileName=['..\CodesV15NewRunForDoubleCheck\Data\VersionInvest_FittingData_Part',num2str(P),'Run',num2str(R),'.mat'];
        Data=load(DataFileName);
        fprintf('Subj=%d\n',Subj)
        
        W=Data.Params(Subj,1)
        Alpha1=Data.Params(Subj,2)
        Alpha2=Data.Params(Subj,3)
        Beta1=Data.Params(Subj,4)
        Beta2=Data.Params(Subj,5)
        Lambda=Data.Params(Subj,6)
        P1=Data.Params(Subj,7)
        P2=Data.Params(Subj,8)
        
        NLL3ParamV1=Data.BestFittedNegLogLikelihood(Subj,1)
        NLL5ParamV1=Data.BestFittedNegLogLikelihood(Subj,4)% MLE
        Err3ParamV1=abs(W-Data.BestFittedParams(Subj,1,1))
        Err5ParamV1=abs(W-Data.BestFittedParams(Subj,1,4))
        AIC3ParamV1=aicbic(-NLL3ParamV1,3)
        AIC5ParamV1=aicbic(-NLL5ParamV1,5)
        if ((NLL5ParamV1<NLL3ParamV1)&&(Err3ParamV1<Err5ParamV1))
            Subj
        end
    end
end
end

